/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.reflection;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author City_Z
 */
public class ReflectionService {
    
    public Object invokeMethod(Class clazz,String nameMethod,Class[] typeParam,Object[] argParam){
        Object obj = null;
        try {          
            Method method1 = clazz.getMethod(nameMethod,typeParam);
            method1.setAccessible(true);
            obj = method1.invoke(argParam);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(ReflectionService.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(ReflectionService.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(ReflectionService.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(ReflectionService.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(ReflectionService.class.getName()).log(Level.SEVERE, null, ex);
        }
         return obj;
    }
}
